<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$return['list']=array();
	$return['credit_types']=credit_types();
	$return['params']['type']=$_RQ['type']?:1;
	set_html('title','积分日志');
	exi($return);
}
if($_RQ['op']=='list'){	
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'merchid'=>$_SESSION['onemerchid'],'plugin'=>'jy_merchjifee');
	$type=intval($_RQ['type']);
	if($type){
		$params['type']=$type;
		$return['params']['type']=$type;
	}
	$credit_types=credit_types();
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	if($_SESSION['onemerchid']){
		$table='jy_merch_creditlog';
	}else{
		$table='core_credit_log';
	}
	$list=pdo_getslice($table,$params,array($pindex,$psize),$total,array('id','type','is_add','fee','remark','createtime'),'','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['is_addtitle']=$item['is_add']?'获得':'消费';
			$item['typetitle']=$credit_types[$item['type']];
		}
	}
	$return['list']=$list;
	exi($return);
}